package cn.iocoder.yudao.adminserver.franky.LRU;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @Description: 懒汉式
 * @Author: franky
 * @CreateDate: 2021/4/16 2:16 下午
 * @Version: 1.0
 */
public class SingletonTwo {
    private static SingletonTwo instance;
    private AtomicLong i = new AtomicLong(0);

    private SingletonTwo() {}

    public static synchronized SingletonTwo getInstance() {
        if (instance == null) {
            instance = new SingletonTwo();
        }
        return instance;
    }

    public long getId() {
        return i.incrementAndGet();
    }

}
